import React, { useMemo } from 'react';
import { Switch } from 'antd'

const App = (props: any) => {

  const { columns, onChange, _dataIndex, value } = props;

  const _options = useMemo(() => {
    if (Array.isArray(columns) && _dataIndex) {
      const _item = columns.filter(item => item.dataIndex === _dataIndex)
      return _item?.[0] || { options: {} }
    } else {
      return { options: {} }
    }

  }, [columns, _dataIndex])

  return <Switch checked={value} onChange={(a, b) => onChange(a)
  } disabled={_options.disabled} />
};

export default App;
